package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.mapper.DtsRegionMapper;
import com.qf.pojo.DtsRegion;
import com.qf.pojo.DtsUser;
import com.qf.service.DtsAdminRegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Service
public class DtsAdminRegionServiceImpl implements DtsAdminRegionService {

    @Autowired
    DtsRegionMapper regionMapper;

    @Override
    public IPage<DtsRegion> queryPage(Integer page, Integer limit,String name,String code) {
        IPage<DtsRegion> ipage = new Page(page, limit);
        LambdaQueryWrapper<DtsRegion> qw=new LambdaQueryWrapper<>();
        if(!StringUtils.isEmpty(name)){
            qw.eq(DtsRegion::getName,name);
        }
        if(!StringUtils.isEmpty(code)){
            qw.eq(DtsRegion::getCode,code);
        }

        regionMapper.selectPage(ipage,qw);
        return ipage;
    }
}
